'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const {
    router,
    controller,
  } = app;
  router.get('/', controller.home.index);
  router.post('/api/v1/user/login', controller.login.login);
  router.post('/api/v1/user/getUser', controller.login.index);
  router.delete('/api/v1/user/outLogin/:id', controller.login.outLogin);

  router.get('/api/v1/user/getCode/:tel', controller.login.getCode);
  router.post('/api/v1/user/telLogin', controller.login.telLogin);

  router.get('/api/v1/user/regTel/:tel', controller.register.getCode);
  router.post('/api/v1/user/regTel', controller.register.regTelSend);
  router.post('/api/v1/user/register', controller.register.register);

  router.post('/api/v1/user/headImg_upload/:id', controller.userSett.headImg_upload);
  router.put('/api/v1/user/setNickName', controller.userSett.setNickName);
  router.put('/api/v1/user/setOther', controller.userSett.setOther);

  router.get('/api/v1/address/:code', controller.userSett.address);

  router.post('/api/v1/receivingaddress/add', controller.receivingAddress.add);
  router.get('/api/v1/receivingaddress/:userid', controller.receivingAddress.getAddress);
  router.put('/api/v1/receivingaddress/upaddress', controller.receivingAddress.upAddress);
  router.del('/api/v1/receivingaddress/deladdress/:id', controller.receivingAddress.delAddress);
  router.put('/api/v1/receivingaddress/setdefault', controller.receivingAddress.setdefault);

  router.get('/api/v1/product/allproducttype/:name1', controller.product.getProduct);
  router.get('/api/v1/product/producttype/:name1/:name2', controller.product.getProduct);
  router.get('/api/v1/product/producttype', controller.product.getType);
  router.get('/api/v1/product/childtype/:id', controller.product.productchildtype);
  router.get('/api/v1/product/:id', controller.product.productId);
  router.get('/api/v1/product/name/:name', controller.product.getTypeProduct);
  router.get('/api/v1/product/all/:name/:pagesize/:page', controller.product.getTypeAllProduct);
  router.get('/api/v1/product/getPrice/:type/:min/:max', controller.product.getPriceProduct);
  router.get('/api/v1/product/:type/:name', controller.product.getProductName);

  router.post('/api/v1/order/addCar', controller.order.addCar);
  router.get('/api/v1/order/getCar/:userid', controller.order.getCar);
  router.del('/api/v1/order/delCar/:id', controller.order.delCar);
  router.put('/api/v1/order/upCar', controller.order.upOrderCar);
  router.put('/api/v1/order/upcarcheck', controller.order.upCarCheck);
  router.put('/api/v1/order/upAllcarcheck', controller.order.upAllCarCheck);
  router.post('/api/v1/order/setOrder', controller.order.setOrder);
  router.put('/api/v1/order/setstate', controller.order.setState);
  router.get('/api/v1/order/getOrder/:userid/:pagesize/:page', controller.order.getOrder);
  router.get('/api/v1/order/getstateOrder/:userid/:pagesize/:page/:state', controller.order.getstateOrder);
  router.del('/api/v1/order/delOrder/:ordernumber', controller.order.delOrder);
  router.get('/api/v1/order/getOrderCount/:uid', controller.order.getOrderCount);
  router.get('/api/v1/order/getOrderId/:id', controller.order.getOrderId);
};
